package com.itheima.youdianda.controller;

import com.itheima.youdianda.common.R;
import com.itheima.youdianda.pojo.YddAdvpos;
import com.itheima.youdianda.service.YddadvposService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 广告位
 */
@RestController
@Slf4j
@RequestMapping("ydd_advpos")
public class YddAdvposController {
    @Autowired
    private YddadvposService service;

    /**
     * 广告位列表分页
     *
     * @param page
     * @param limit
     * @param advposdesc
     * @param advposname
     * @return
     */
    @GetMapping("list")
    public R advposList(@RequestParam(value = "page", required = false, defaultValue = "1") Integer page,
                        @RequestParam(value = "limit", required = false, defaultValue = "10") Integer limit,
                        String advposdesc, String advposname) {
        return service.advposList(page, limit, advposname, advposdesc);
    }

    /**
     * 广告位修改
     *
     * @param yddAdvpos
     * @return
     */
    @PostMapping("update")
    public R advposUpdate(@RequestBody YddAdvpos yddAdvpos) {
        return service.advposUpdate(yddAdvpos);
    }

    /**
     * 广告位删除
     *
     * @param id
     * @return
     */
    @GetMapping("del")
    public R del(Integer id) {
        return service.del(id);
    }

    /**
     * 广告位列表全部
     *
     * @return
     */
    @GetMapping("all")
    public R getAll() {
        //TODO 广告位列表全部
        return service.getAll();
    }

    /**
     * 广告位详情
     *
     * @param id
     * @return
     */
    @GetMapping("rowInfo")
    public R rowInfo(Integer id) {
        return service.rowInfo(id);
    }

    /**
     * 广告位添加
     *
     * @param yddAdvpos
     * @return
     */
    @PostMapping("add")
    public R advposAdd(@RequestBody YddAdvpos yddAdvpos) {
        return service.advposAdd(yddAdvpos);
    }


}
